package org.langke.design.pattern.strategy;

/**
 * 订单类
 */
public class Order {
    private String uid;
    private String orderId;
    private Double amount;
    public Order(String uid,String orderId,Double amount){
        this.uid = uid;
        this.orderId = orderId;
        this.amount = amount;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }
    public PayResult pay(String payType){
        PaymentStrategy paymentStrategy = PaymentFactory.getInstance(payType);
        System.out.println("欢迎使用"+paymentStrategy.getName());
        System.out.println("本次交易金额为：" + amount + "元，开始扣款...");
        return paymentStrategy.pay(uid,amount);
    }
}
